package com.cm.study.other.reflect;

import java.lang.reflect.Field;

public class ReflectStudyObjectTest {
    public static void main(String[] args) throws IllegalAccessException, NoSuchFieldException {
        ReflectStudyObject object = new ReflectStudyObject();
        /*Constructor<?>[] declaredConstructors = ReflectStudyObject.class.getDeclaredConstructors();
        System.out.println("declaredConstructors = " + declaredConstructors);
        for (Constructor<?> declaredConstructor : declaredConstructors) {
            Type[] genericParameterTypes = declaredConstructor.getGenericParameterTypes();
            Parameter[] parameters = declaredConstructor.getParameters();
            for (Type genericParameterType : genericParameterTypes) {
                String typeName = genericParameterType.getTypeName();
                System.out.println("typeName = " + typeName);
            }
            for (Parameter parameter : parameters) {
                System.out.println("parameter = " + parameter.getName());
                int modifiers = parameter.getModifiers();
                System.out.println("modifiers = " + modifiers);
                String typeName = parameter.getType().getTypeName();
                System.out.println("typeName = " + typeName);
            }
        }*/
        //Object o = Array.newInstance(ReflectStudyObject.class, 10);
        ///System.out.println("o = " + o);
        /*String[] strs = (String[]) Array.newInstance(String.class, 20);
        strs[0] = "000";
        strs[1] = "111";
        Object o = Array.get(strs, 1);
        System.out.println("o = " + o);
        String typeName = ReflectStudyObject.class.getTypeName();
        System.out.println("typeName = " + typeName);
        System.out.println("ReflectStudyObject.class.getDeclaredAnnotations() = " + ReflectStudyObject.class.getDeclaredAnnotations());

*/
        //Field id = object.getClass().getField("id");
        Field[] fields = ReflectStudyObject.class.getDeclaredFields();
        for (Field field : fields) {
            System.out.println("field = " + field.getName());
        }
        Field[] fields1 = ReflectStudyObject.class.getFields();
        for (Field field : fields1) {
            System.out.println("field1 = " + field.getName());
        }
        // id.set(object,123);
        //System.out.println("id = " + object.getId());
    }
}
